package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Wine;
import com.xx.pmis.persistence.dao.WineDAO;
import com.xx.pmis.services.WineService;

public class WineServiceImpl implements WineService {
	WineDAO wineDAO = null;

	public WineServiceImpl(WineDAO wineDAO) {
		super();
		this.wineDAO = wineDAO;
	}

	public void saveOrUpdateWine(Wine wine) throws Exception {
		wineDAO.saveOrUpdate(wine);
	}

	public void saveWine(Wine wine) throws Exception {
		wineDAO.save(wine);
	}

	public void deleteWine(Wine wine) throws Exception {
		wineDAO.delete(wine);
	}

	public Wine getWineByWineID(String wineID) throws Exception {
		Wine wine = wineDAO.getWineByWineID(wineID);
		return wine;
	}


	
	public List<Wine> getAllWineByCondition(String hql) throws Exception {
		List<Wine> wines = wineDAO.getAllWineByCondition(hql);
		return wines;
	}
	
	public List<Wine> getAllWineByConditionByPage(String hql, int currentPage, int lineSize) throws Exception {
		List<Wine> wines = wineDAO.getAllWineByConditionByPage(hql, currentPage, lineSize);
		return wines;
	}
	
	public int getCountOfWineByCondition(String hql) throws Exception {
		return wineDAO.getAllWineByCondition(hql).size();
	}

}
